package com.gangan.controller.web;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gangan.controller.common.BaseController;
import com.gangan.model.HospitalSynopsis;
import com.gangan.model.Order;
import com.gangan.service.IHospitalSynosisService;
import com.gangan.service.IOrderService;
import com.gangan.tools.MessageBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jobob
 * @since 2019-09-26
 */
@Api(description = "*首页管理医院简介控制层")
@RestController
@RequestMapping("/hospitalSynopsis")
public class HospitalSynopsisController extends BaseController {

    @Autowired
    IHospitalSynosisService hospitalSynosisService;

    @RequestMapping(value = "/list",method = RequestMethod.GET)
    @ApiOperation(value="数据列表", notes="根据相关条件查询列表数据")
    public MessageBean list(Page page){
        return resultSuccess(hospitalSynosisService.page(page, Wrappers.<HospitalSynopsis>query().lambda().orderByDesc(HospitalSynopsis::getUpdateTime)));
    }

    @RequestMapping(value = "/del",method = RequestMethod.POST)
    @ApiOperation(value="移除数据", notes="根据自增主键移除数据")
    public MessageBean del(Integer id){
        return resultSuccess(hospitalSynosisService.removeById(id));
    }

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @ApiOperation(value="新增数据", notes="将提交的数据保存到数据库")
    public MessageBean add(HospitalSynopsis add){
        return resultSuccess(hospitalSynosisService.save(add));
    }

    @RequestMapping(value = "/edit",method = RequestMethod.POST)
    @ApiOperation(value="编辑数据", notes="根据主键修改数据")
    public MessageBean edit(HospitalSynopsis edit){
        return resultSuccess(hospitalSynosisService.updateById(edit));
    }

}
